{%include file="header.html"%}
<style>
  table{text-align: center;}
  th{text-align:center; font-weight: bolder;}
  th a{ color:#000000;}
.firtd {	width: 100px;	padding-right: 10px;	text-align: right;}
input {	width: 350px;}
textarea {	width: 350px;	height: 100px;}
</style>
<body>
<div class="fixed-bar">
  <div class="item-title">
    <h3>文章分类列表</h3>
    <select name="cat_id">
    	<!-- <option value="0">所有分类</option> -->
       {%$type%}
    </select>
    <input value=" 搜索 " id="but_sousuo" style="width:40px; height:27px; margin-top:13px;" class="button" type="submit">
    <script>
    	$("#but_sousuo").click(function(){ 
			var cat_id=$("select[name=cat_id]").val();
			location.href="news_type.php?act=list&cat_id="+cat_id;
		});
    </script>
    <div style="background:rgba(251,112,45,1);width:125px;height:40px;float:right;text-align:center;border-radius:5px;">
      <a href="news_type.php?act=add">
        <h5 style="padding:10px;color:#fff;">
          添加文章分类
        </h5>
      </a>
    </div>
  </div>
</div>
<div class="fixed_bottom">
  <form method="post" action="" id="aspnetForm" name="form1">
    <table align="center;" class="table tb-type2">
      <thead>
        <tr>
          <th><a>文章分类名称</a></th>
          <th><a>分类类型</a></th>
          <th><a>描述</a></th>
          <th><a>排序</a></th>
          <th><a>操作</a></th>
        </tr>
      </thead>
      <tbody id="sortable">
        {%foreach from=$list item=list1 key=k%}
            <tr id="{%$list1.cat_id%}" alt="{%$list1.cat_id%}">
              <td>{%$list1.cat_name%}</td>
              <td>{%$list1.cat_type%}</td>
              <td>{%$list1.cat_desc%}</td>
              <td>{%$list1.sort_order%}</td>
              <td>
                <a href="news_type.php?act=add&cat_id={%$list1.cat_id%}">编辑</a>
                <a href="javascript:;" onclick="get_article_cat(this,{%$list1.cat_id%})" style="{%if $list1.cat_id==1%}display:none;{%elseif  $list1.parent_id==1%}display:none;{%/if%}">删除</a>
              </td>
            </tr>
        {%/foreach%}
      </tbody>
      <input type="hidden" id="ids_list" />
    </table>
    <div class="page">{%$page%}</div>
  </form>
</div>
</body>
<script>
//是否显示在导航栏 
function get_show_price(obj,id,price){
  if(price==1){
    prices="1";
  }else{
    prices="2";
  }
  $.post("news_type.php",{act:'show',cat_id:id,zt:prices},function(data){
    if(data==1){
      layer.msg("操作成功！");
      if(prices==1){
        $(obj).attr("onclick","get_show_price(this,"+id+",2)");
        $(obj).removeClass("fa-check");
        $(obj).addClass("fa-close");
      }else if(prices==2){
        $(obj).attr("onclick","get_show_price(this,"+id+",1)");
        $(obj).removeClass("fa-close");
        $(obj).addClass("fa-check");
      }
    }else if(data==2){
      layer.msg("操作失败！");
    }
  })
}
//ajax删除文章分类
function get_article_cat(obj,id){
  $.post("news_type.php",{act:'delete',cat_id:id},function(data){
    if(data==3){
      layer.alert("该分类下还有子分类，请先删除其子分类");
      return false;
    }else if(data==1){
      layer.msg("操作成功! ");
      $('#'+id).remove();
    }else if(data==2){
      layer.msg("操作失败！");
    }

  }) 
}
</script>
</html>